﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Abp.Application.Services.Dto;
using Abp.AspNetCore.Mvc.Authorization;
using DevM.Authorization;
using DevM.Controllers;
using DevM.Users;
using DevM.Web.Models.Users;
using DevM.Users.Dto;
using DevM.Development.Projects;
using DevM.Web.Models.Projects;
using DevM.Development.Projects.Dto;
using DevM.Development.DynamicInfomations;
using DevM.Development.DynamicInfomations.Dto;
using DevM.Web.Models.DynamicInfomations;

namespace DevM.Web.Controllers
{
    [AbpMvcAuthorize(PermissionNames.Pages_Projects)]
    public class DynamicInfomationsController : DevMControllerBase
    {
        private readonly IProjectAppService projectAppService;
        private readonly IUserAppService userAppService;
        private readonly IDynamicInfomationAppService dynamicInfomationAppService;

        public DynamicInfomationsController(IProjectAppService projectAppService, IUserAppService userAppService, IDynamicInfomationAppService dynamicInfomationAppService)
        {
            this.projectAppService = projectAppService;
            this.userAppService = userAppService;
            this.dynamicInfomationAppService = dynamicInfomationAppService;
        }

        public async Task<ActionResult> Index(GetDynamicInfomationListInput input)
        {
            var infos = await dynamicInfomationAppService.GetDynamicInfomations(input);

            var project = await projectAppService.GetProject(new EntityDto<long>(input.ProjectId));
            var model = new DynamicInfomationsListViewModel
            {
                Project = project,
                DynamicInfomations = infos
            };
            return View(model);
        }
    }
}
